﻿using System;
using System.Collections.Generic;
using System.Threading.Tasks;

using ApproveFlowEngine.Approve;
using ApproveFlowEngine.Approve.DTO;

using Volo.Abp.Account;
using Volo.Abp.DependencyInjection;

namespace ApproveFlowEngine.HttpApi.Client.ConsoleTestApp;

public class ClientDemoService : ITransientDependency
{
    #region Private Fields

    private readonly IApproveAppService _approveAppService;
    private readonly IProfileAppService _profileAppService;

    #endregion Private Fields

    #region Public Constructors

    public ClientDemoService(IProfileAppService profileAppService, IApproveAppService approveAppService)
    {
        _profileAppService = profileAppService;
        _approveAppService = approveAppService;
    }

    #endregion Public Constructors



    #region Public Methods

    public async Task Create_Data_Should_Successed()
    {
        var data = new WorkFlowDto()
        {
            FlowName = "Test",
            FlowNo = 1,
            ApproveType = Enums.Core.ApproveType.General,
            IsDraft = false,
            Remark = "测试用例",
            Nodes = new List<WorkNodeDto>
                {
                    new WorkNodeDto()
                    {
                        Index=1,
                        NodeType=Enums.Core.NodeType.Simple,
                    },
                    new WorkNodeDto()
                    {
                        Index=2,
                        NodeType=Enums.Core.NodeType.Simple,
                    },
                    new WorkNodeDto()
                    {
                        Index=3,
                        NodeType=Enums.Core.NodeType.Simple,
                    },
                    new WorkNodeDto()
                    {
                        Index=4,
                        NodeType=Enums.Core.NodeType.Simple,
                    },
                    new WorkNodeDto()
                    {
                        Index=5,
                        NodeType=Enums.Core.NodeType.Simple,
                    }
                }
        };
        await _approveAppService.Create(data);
    }

    public async Task RunAsync()
    {
        await Create_Data_Should_Successed();
        var output = await _profileAppService.GetAsync();
        Console.WriteLine($"UserName : {output.UserName}");
        Console.WriteLine($"Email    : {output.Email}");
        Console.WriteLine($"Name     : {output.Name}");
        Console.WriteLine($"Surname  : {output.Surname}");
    }

    #endregion Public Methods
}